home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok17.lha
/
IFFtoImage
/
Sources
/
IFFtoImage.mod
< prev
next >
Wrap
Text File
|
1993-08-15
|
5KB
|
141 lines
(*---------------------------------------------------------------------------
:Program. IFFtoImage.mod
:Author. Jochen P. Kupfer
:Address. Buchenweg 22, D-4006 Erkrath 2
:Phone. 02104-40673
:Shortcut. [SIGMA]
:Version. 1.0
:Date. 3/23/89
:Copyright. PD
:Language. Modula-2
:Translator. M2Amiga V 3.2
:Imports. LoadIFF.mod [fbs] & LoadBody [fbs]
:UpDate. none
:Contents. Converts IFF-Brush to ImageData-File.
:Remark. Derived from Pit Burkardt's IFFtoCode.mod on Amok # 3.
---------------------------------------------------------------------------*)
MODULE IFFtoImage;
FROM SYSTEM IMPORT ADR, ADDRESS, SHIFT;
FROM Exec IMPORT UByte;
FROM Intuition IMPORT ScreenPtr,WindowPtr,CloseScreen;
FROM Arguments IMPORT NumArgs,GetArg;
FROM Arts IMPORT TermProcedure,Assert, CurrentLevel;
FROM IFFLoad IMPORT ReadILBM,ReadILBMFlags,ReadILBMFlagSet,IFFInfo;
FROM Graphics IMPORT RastPortPtr,BitMapPtr;
FROM InOut IMPORT WriteString,WriteLn;
FROM Str IMPORT Concat;
FROM FileSystem IMPORT Lookup, WriteBytes, Close, File,
WriteChar, Response, WriteByteBlock;
VAR MyScreen,
MyOldScreen :ScreenPtr;
MyWindow :WindowPtr;
Name :ARRAY[0..79] OF CHAR;
length,i :INTEGER;
Error :BOOLEAN;
BitMaps :ARRAY[0..5] OF ADDRESS;
ScLineLength,
LineLength,
Plane :LONGINT;
Pictheight,
Pictdepth,
Pictwidth :LONGINT;
AnzEingaben :INTEGER;
RP :RastPortPtr;
BM :BitMapPtr;
myLevel :INTEGER;
data :File;
PROCEDURE CleanUp;
BEGIN
IF myLevel>=CurrentLevel() THEN
IF MyScreen#NIL THEN CloseScreen(MyScreen) END;
END;
END CleanUp;
PROCEDURE MovePlaneDat(BitMaps:ARRAY OF ADDRESS;Pictwidth,Pictheight,
Pictdepth,ScLineLength:LONGINT);
VAR Location :POINTER TO UByte;
Plane :CARDINAL;
Line,Bs :LONGINT;
BEGIN (* of MovePlaneDat *)
FOR Plane := 0 TO Pictdepth-1 DO
FOR Line := 0 TO Pictheight-1 DO
FOR Bs := 0 TO Pictwidth-1 BY 2 DO (* need an even numer of bytes *)
Location:=ADDRESS(BitMaps[Plane]+ ScLineLength*Line+Bs);
WriteChar(data,CHAR(Location^));
Location:=ADDRESS(BitMaps[Plane]+ ScLineLength*Line+Bs+1);
WriteChar(data,CHAR(Location^));
END; (*FOR Pictwidth*)
END; (*FOR Line*)
END; (*FOR Plane*)
END MovePlaneDat;
TYPE
BLOCK = RECORD
CASE :BOOLEAN OF
| TRUE : l:ARRAY[0..2] OF LONGINT;
| FALSE: b:ARRAY[0..11] OF UByte;
END;
END;
VAR
block :BLOCK;
BEGIN (* MAIN *)
myLevel := CurrentLevel();
TermProcedure(CleanUp);
AnzEingaben:=NumArgs();
IF AnzEingaben=0 THEN
WriteString("Sorry, can't work - no Input!"); WriteLn;WriteLn;
WriteString("From CLI: Name IFF-file as option."); WriteLn;WriteLn;
WriteString("From Workbench: <SHIFT>-klick IFF-file,"); WriteLn;
WriteString("then <SHIFT>-doubleklick IFFtoImage"); WriteLn; WriteLn;
ELSE
GetArg(1,Name,length);
MyOldScreen:=MyScreen;
IF MyOldScreen<>NIL THEN CloseScreen(MyOldScreen) END;
Error:=ReadILBM(Name,ReadILBMFlagSet{visible},MyScreen,MyWindow);
Assert((Error),ADR("Error while lading ILBM-File"));
Pictdepth:=IFFInfo.BMHD.depth; (* dimensions in pixels *)
Pictheight:=IFFInfo.BMHD.height;
Pictwidth:=IFFInfo.BMHD.width;
LineLength := (Pictwidth+7) DIV 8;(* Zeilenlänge in Bytes, aufgerundet *)
IF LineLength*8<Pictwidth THEN
WriteString("(* Brushbreite gegenüber IFF geändert! *)"); WriteLn;
LineLength:=LineLength+2;
END;
ScLineLength:= MyScreen^.width DIV 8;
RP := ADR(MyScreen^.rastPort);
BM := RP^.bitMap;
FOR i:=0 TO Pictdepth-1 DO
BitMaps[i] := BM^.planes[i];
END;
Concat(Name,".img");
block.l[0] := Pictwidth; (* no of pixels per line *)
block.l[1] := Pictheight; (* no of lines *)
block.l[2] := Pictdepth; (* no of BitPlanes *)
Lookup(data,Name,1024,TRUE);
WriteByteBlock(data,block.b);
Assert(data.res=done,ADR("coudn't write block.b"));
MovePlaneDat(BitMaps,LineLength,Pictheight,
Pictdepth,ScLineLength);
Close(data);
WriteLn;
WriteString("Thanks! It was a pleasure to work with you ...");
WriteLn;
END; (*IF*)
END IFFtoImage.mod